class B implements Runnable{
    String name;
    long SleepTime;
    public B(String name,long SleepTime){
        this.name=name;
        this.SleepTime=SleepTime;
    }
    public void run(){
        for(int i=0;i<20;i++){
            System.out.println(name+"   "+i);
        }
        try{
            Thread.sleep(SleepTime);//直接继承的话可以不用Thread
        }catch(InterruptedException e){}
    }
}
public class TestDemo2{
    public static void main(String[] args){
        B a=new B("快线程",1000);
        B b=new B("慢线程",2000);
        Thread s1=new Thread(a);
        Thread s2=new Thread(b);
        s1.start();
        s2.start();
    }
}
